<template>
  <div>
    <el-dialog title="修改或新增" :visible.sync="dialogVisible" width="400px">
      <el-form class="demo-form-inline" label-width="80px">
        <el-form-item label="权限名称" required>
          <el-input v-model="data.purviewName" />
        </el-form-item>

        <el-form-item label="禁/启用" required>
          <el-select v-model="data.isUse" placeholder="请选择" clearable>
            <el-option
              v-for="item in isUseList"
              :label="item.isUse"
              :value="item.value"
              :key="item.value"
            ></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="权限编码" required>
          <el-input v-model="data.purviewCode" />
        </el-form-item>
      </el-form>

      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="submit()">提 交</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import apisystemmenu from "@/api/baseManager/systemmenu";
export default {
  name: "dialogAuthEdit",
  data() {
    return {
      dialogVisible: false,
      data: this.initData(),
      isUseList: apisystemmenu.isUseList
    };
  },
  methods: {
      initData(){
        return {
          purviewName: "", //权限名称
          isUse: 1, //状态
          purviewType:2,
          purviewCode: "_role_" //权限编码
        }
      },
      
    //编辑
    openseeedit(row) {
      this.dialogVisible = true;
      apisystemmenu.getOneItouchSysPurview({ purviewId: row.purviewId }).then(res => {
          this.data = res.data.dto;
        });
    },
    //新增
    openseeadd(parentId) {
      this.data = this.initData();
      this.data.parentId = parentId
      this.dialogVisible = true;
    },
    //提交
    submit() {
      apisystemmenu.saveOrUpdatePurview(this.data).then(res => {
        this.$parent.getList();
        this.dialogVisible = false;
      });
    }
  }
};
</script>

<style scoped>
</style>